{% extends 'admin/layout/base.html.twig' %}

{% block content %}

<div class="main">
    <!-- MAIN CONTENT -->
    <div class="main-content">
        <div class="container-fluid">
            <!-- OVERVIEW -->
             <div class="row">
                <div class="panel">
                    <div class="panel-heading">
                        <h3 class="panel-title">Setting</h3>
                    </div>
                    <div class="panel-body">
                        <div class="input-group">
                            <span class="input-group-btn">
                                <button class="btn btn-primary" type="button">Old Password</button>
                            </span>
                            <input class="form-control old-pwd" type="password">
                        </div>
                        <br>
                        <div class="input-group">
                            <span class="input-group-btn">
                                <button class="btn btn-primary" type="button">New Password</button>
                            </span>
                            <input class="form-control new-pwd1" type="password">
                        </div>
                        <br>
                        <div class="input-group">
                            <span class="input-group-btn">
                                <button class="btn btn-primary" type="button">Confirm</button>
                            </span>
                            <input class="form-control new-pwd2" type="password">
                        </div>
                        <br>
                        <div class="input-group">
                            <button type="button" class="btn btn-success submit-btn">Submit</button>&nbsp;&nbsp;&nbsp;&nbsp;
                            <a type="button" class="btn btn-default">Cancel</a>
                        </div>
                        <br>
				    </div>
                </div>	
            </div>	
        </div>
    </div>
</div>    
{% endblock %}
{% block jscript %}
    <script type="text/javascript">
        $("body").on('click','.submit-btn',function(){
            var _this = $(this);
            var old=$(".old-pwd").val();
            var newpwd1=$(".new-pwd1").val();
            var newpwd2=$(".new-pwd2").val();
            if(!old||!newpwd1){
                layer.msg("新旧密码未填写！");
                return false;
            }
            if(newpwd1!==newpwd2){
                layer.msg("两次密码输入不一致");
                return false;
            }
            var index = layer.load(1, {
                    shade: [0.1,'#fff'] 
                    });
            $.post("{{path('settingStore')}}",{old:old,newpwd1:newpwd1,newpwd2:newpwd2},function(result){
                console.log(result);
                if(result['errno']==0){
                    layer.close(index);
                    layer.msg('Success !', {icon: 1});
                } else {
                    layer.close(index);
                    layer.msg(result['message'], {icon: 0});
                }
            });
        })
    </script>
{% endblock %}

